package io.seata.sample.service.impl;

import io.seata.sample.dao.StockMapper;
import io.seata.sample.service.StockService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: linKe
 * @Date: 2022/1/25 10:23
 * @FileName: StockServiceImpl
 * @version: 1.0
 * @Description: 描述
 */
@Service("stockServiceImpl")
public class StockServiceImpl implements StockService {

    private static final Logger LOGGER = LoggerFactory.getLogger(StockServiceImpl.class);

    @Autowired
    private StockMapper stockMapper;

    /**
     * 扣减库存
     *
     * @param productId 产品id
     * @param count     数量
     * @return
     */
    @Override
    public void decrease(Long productId, Integer count) {
        LOGGER.info("------->扣减库存开始");
        stockMapper.decrease(productId, count);
        LOGGER.info("------->扣减库存结束");
    }
}

